package com.woniu.service.imp;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInterceptor;
import com.woniu.bean.UserVo;
import com.woniu.mapper.UserMapper;
import com.woniu.pojo.User;
import com.woniu.service.UserService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImp implements UserService {
    private Logger logger=Logger.getLogger(this.getClass());

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findUserByUid(String telephone,String password) {
        return userMapper.selectUserByUid(telephone,password);
    }
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    @Override
    public List<User> findUsersBypage(UserVo userVo) {
        PageHelper.startPage(userVo.getPageSize(),userVo.getCount());
        return userMapper.selectUsersByPage(userVo);
    }

    @Override
    public void addUser(User user) {
        userMapper.insertUser(user);
    }
}
